package stream;
import method_references.Employee;
import method_references.EmployeeData;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * @author mubei
 * @date 2021/11/24
 * @description
 */
public class StreamAPITest {

    public static void main(String[] args) {
        // 通过集合进行创建

    }

    @Test()
    public void test1() {
        List<Employee> list = EmployeeData.getAllEmployees();
        //两类流   并行流
        Stream<Employee> stream = list.stream();
        Stream<Employee> parallelStream = list.parallelStream();
    }

    @Test()
    public void test2() {
        int[] arr = new int[]{1,2,3};
        IntStream stream = Arrays.stream(arr);
    }


    @Test()
    public void test3() {
        Stream<Integer>stream = Stream.of(1,2,3,5);
    }

    @Test()
    public void test4() {
        // 遍历前10个偶数
        //   public static<T> Stream<T> iterate(final T seed, final UnaryOperator<T> f) {
        Stream.iterate(0,t -> t+2).limit(10).forEach(System.out::println);
        
        Stream.generate(Math::random).limit(10).forEach(System.out::println);
    }
}
